export default {
  namespaced: true,
  state: {
    smtp: '', // 邮箱服务器地址
    port: '', // 邮箱服务器端口
    mailName: '', // 系统邮箱地址
    mailPassword: '', // 系统邮箱密码
    projectId: localStorage.getItem('projectId'),      // 项目ID
    projectName: localStorage.getItem('projectName'),    // 项目名称
    /*
     密码安全配置
    */
   	loginOutMinute: '',
   	minPwdLength: '',
   	pwdChangeDays: '',
   	pwdChangeForce: '',
   	pwdRecordCount: '',
    loginFailCountLock: '',
   	loginFailLockTime: '',
    operCert: '',
    /*
     阿里大鱼配置信息
    */
    accessKeyId: '', // 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
    accessKeySecret: '', // 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
    signature: '', // 必填:短信签名-可在短信控制台中找到
    templateCode: '', // 必填:短信模板-可在短信控制台中找到-->
    /*
      外观配置
    */
    defaultTheme: localStorage.getItem('defaultTheme'), // 默认主题
    defaultLayout: localStorage.getItem('defaultLayout'),
    productName: '', // 产品名称
    logo: '', // 产品logo: '',
    /*
      后台参数
    */
    backParam: {
      functionList: [],
      onlineTime: 1200,
      userType1:"https://xcfiles.oss-cn-shanghai.aliyuncs.com/xufuji/78a9_35583aeeba030a9cf7f65b98cb5cc65e.png",
      userType2:"https://xcfiles.oss-cn-shanghai.aliyuncs.com/xufuji/mj4s_f1da4716e2536562d6edd55061f04f8e.png",
      userType3:"https://xcfiles.oss-cn-shanghai.aliyuncs.com/xufuji/b6p1_d478f7642705028a3ceab26151036d81.png",
      userType4:"https://xcfiles.oss-cn-shanghai.aliyuncs.com/xufuji/ljov_31625b36e6129c50da70b3384d704aaa.png"
    },
    /*
     商户图片
    */
    merchant: [],
    /*
     业态图片
    */
    merchantsType: [],
    /*
     公共设施类型图片
    */
    utilitiesType: []
  },
  mutations: {
    updateProjectId (state, val) {
      if(val != localStorage.getItem('projectId') ) {
        localStorage.clear();
      }
      state.projectId = val
      localStorage.setItem("projectId", val);
    },
    updateProjectName (state, val) {
      state.projectName = val
      localStorage.setItem("projectName", val);
    },
    updateDefaultTheme (state, val) {
      state.defaultTheme = val
    },
    updateDefaultLayout (state, val) {
      state.defaultLayout = val
    },
    updateProductName (state, val) {
      state.productName = val
    },
    updateLogo (state, val) {
      state.logo = val
    },
    updateBackParam (state, val) {
      state.backParam = val
    },
    updateMerchant (state, val) {
      if (!val) {
        state.merchant = []
      } else {
        state.merchant = val
      }
      state.merchant.forEach((item) => {
        if (item.valueStr && item.valueStr.length > 4) {
          item.value = JSON.parse(item.valueStr)
        }
      })
    },
    updateMerchantsType (state, val) {
      if (!val) {
        state.merchantsType = []
      } else {
        state.merchantsType = val
      }
      state.merchantsType.forEach((item) => {
        if (item.valueStr && item.valueStr.length > 4) {
          item.value = JSON.parse(item.valueStr)
        }
      })
    },
    updateUtilitiesType (state, val) {
      if (!val) {
        state.utilitiesType = []
      } else {
        state.utilitiesType = val
      }
      state.utilitiesType.forEach((item) => {
        if (item.valueStr && item.valueStr.length > 4) {
          item.value = JSON.parse(item.valueStr)
        }
      })
    },
    updateConfig (state, config) {
      state.smtp = config.smtp
      state.port = config.port
      state.mailName = config.mailName
      state.mailPassword = config.mailPassword
      state.accessKeyId = config.accessKeyId
      state.accessKeySecret = config.accessKeySecret
      state.signature = config.signature
      state.templateCode = config.templateCode
      state.defaultTheme = config.defaultTheme
      state.defaultLayout = config.defaultLayout
      state.productName = config.productName
      state.logo = config.logo

      state.loginOutMinute =  config.loginOutMinute
      state.minPwdLength =  config.minPwdLength
      state.pwdChangeDays =  config.pwdChangeDays
      state.pwdChangeForce =  config.pwdChangeForce
      state.pwdRecordCount =  config.pwdRecordCount
      state.loginFailCountLock =  config.loginFailCountLock
      state.loginFailLockTime =  config.loginFailLockTime
      state.operCert =  config.operCert
    }
  }
}
